function error = fitness(Wvec, trainSet, expectedOutput)
    %expectedOutput = z';
    %pointsSet = [x y];
    %trainSet = horzcat(trainSet, ones(rows(trainSet), 1)*-1);
    for i=1:rows(trainSet)
        currentPattern = trainSet(i,:)';
        for j=1:cols(Wvec)
            h = Wvec{j}*currentPattern;
            currentPattern = g(h);
            currentPattern = vertcat(currentPattern, -1);
        end
        testOutputs(i) = currentPattern(1);
    end
    obtainedOutput = testOutputs;
    error = cuadraticError(obtainedOutput,expectedOutput');
    error = error*-1;
end

function ans=g(x)
    beta=0.25;
    ans = tanh(beta*x);       
end